package com.spoto.oa.util;


import java.io.File;
import java.util.Date;

import com.oreilly.servlet.multipart.FileRenamePolicy;



public class RandomFileRenamePolicy implements FileRenamePolicy {
	
	private String fileName=null;

    public File rename(File file) {
      String body="";
      String ext="";
      Date date = new Date();
      int pot=file.getName().lastIndexOf(".");
      if(pot!=-1){
          body= date.getTime() +"";
          ext=file.getName().substring(pot);
      }else{
          body=(new Date()).getTime()+"";
          ext="";
      }
      String newName=body+ext;
      fileName=newName;
      file=new File(file.getParent(),newName);//在原有文件吧下创建文件
      return file;

    }

	public String getFileName() {
		return fileName;
	}

	public void setFileName(String fileName) {
		this.fileName = fileName;
	}

}